<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Edit Post</title>
    <link href="/static/roboto/roboto.css" rel="stylesheet">
    <link rel="stylesheet" href="/static/edit.css">
</head>
<body>
<div class="topnav">
    <a onclick="sendForm()">Save and back</a>
    <a onclick="confirmDeletion()">Delete Post</a>
</div>
<div class="data">
    <form id="editForm" action="/admin/" method="post">
    <div class="p2">
    <p>Title</p>
    <input type="text" name="title" value="{{.Title}}">
    </div>

    <div class="p2">
        <p>Description</p>
        <textarea name="desc" class="p4" rows="1">{{.Desc}}</textarea>
    </div>
    <div class="p2">
        <p>Image Link(empty to none)</p>
        <input type="text" name="img" value="{{.Img}}">
    </div>
    <div class="p2">
        <p>Post Text(markdown)</p>
        <textarea name="post" class="p4" rows="40">{{.PostText}}</textarea>
    </div>
        <input type="hidden" name="postId" value="{{.Id}}" />
    </form>

</div>
<script>
    function sendForm(){
        document.getElementById("editForm").submit();
    }
    function confirmDeletion() {
        let confirmDeletion = confirm("Delete this post?");
        if (confirmDeletion == true) {
            let confirmDeletionDouble = confirm("Delete this post?(Double check)")
            if (confirmDeletionDouble == true) {
                window.location.href = "/admin/delete/{{.Id}}";
            }
        }

    }
</script>
</body>
</html>